package edit;

import pulpcore.Input;
import draw.DrawBoxSprite;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.joints.Joint;
import pulpfizz.physics.BodyUtils;
import pulpfizz.physics.Material;
import pulpfizz.physics.JointUtils;
import pulpfizz.pulp.body.Java2DBodySprite;
import goliath.BasicDemo;

/**
 * Simple pin context - create a new RevoluteJoint (pin) wherever the user clicks!
 * @author will
 * @date Aug 10, 2008 2:33:16 PM
 */
public class PinContext extends EditContext {

    public void update(int elapsedTime) {
        if(Input.isMousePressed()) {
            Body pinBody = BodyUtils.createCircle(layer.getWorld(),mousePos.x,mousePos.y, 0.1f);
            Joint j = JointUtils.createRevoluteJoint(layer.getWorld(),this.mousePos);
            Java2DBodySprite bs = new Java2DBodySprite(pinBody,layer,1, BasicDemo.getDrawColor(), BasicDemo.getFillColor());
            layer.add(bs);
        }
    }

    public void reset() {
    }

    public String toString() {
        return "Pin";
    }
}
